package org.datascooter.db.oracle;

import java.sql.SQLException;

import javax.sql.ConnectionPoolDataSource;

import oracle.jdbc.pool.OracleConnectionPoolDataSource;

import org.datascooter.impl.ContextConnector;
import org.datascooter.inface.IDataSource;

public class OracleConnector extends ContextConnector {

	private OracleConnectionPoolDataSource poolDataSource;

	public OracleConnector() {
	}

	public OracleConnector(IDataSource source) throws SQLException {
		super(source);
	}

	@Override
	public ConnectionPoolDataSource createPooledDataSource() throws SQLException {
		if (poolDataSource == null) {
			poolDataSource = new OracleConnectionPoolDataSource();
			poolDataSource.setURL(dataSource.getURL());
			poolDataSource.setUser(dataSource.getUser());
			poolDataSource.setPassword(dataSource.getPassword());
		}
		return poolDataSource;
	}

	@Override
	public boolean isSupportPagination() {
		return true;
	}

	@Override
	public String getContextId() {
		return "oracle";
	}
}
